<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>大麦商城</title>
<link href="css/slider.css" rel="stylesheet" type="text/css"/>
<link href="css/common.css" rel="stylesheet" type="text/css"/>
<link href="css/index.css" rel="stylesheet" type="text/css"/>
	<script src="https://unpkg.com/vue@2.7.14/dist/vue.min.js"></script>
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"></script>
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<script src="/user/login/js/login.js"></script>
	<script src="/js/damai.js"></script>
	<style>
		#dacu>img:hover{
			transform: scale(1.1);
			cursor: pointer;
			box-shadow: 2px 5px 5px 5px #999999;
		}
	</style>
</head>
<body>
<div id="app">
	<damai ref="dm">
		<div class="container index">
			<div v-if="dacuTime.beginTime" class="span24">
				<h1>限时秒杀
					<small>{{dacuStopTime.toISOString().replace(/.+(\d{2}:\d{2}:\d{2}).+/,"$1")}}</small>
				</h1>
				<div id="dacu">
					<img v-for="p in dacuProducts" :src="p.image" @click="seckill(p.pid)"
						style="width: 80px; height: 80px; margin: 5px;transition: all 0.5s">
				</div>
			</div>

			<div class="span24">
				<div id="hotProduct" class="hotProduct clearfix">
					<div class="title">
						<strong>热门商品</strong>
						<!-- <a  target="_blank"></a> -->
					</div>
					<ul class="tab">
						<li class="current">
							<a href="./蔬菜分类.htm?tagIds=1" target="_blank"></a>
						</li>
						<li>
							<a  target="_blank"></a>
						</li>
						<li>
							<a target="_blank"></a>
						</li>
					</ul>
					<ul class="tabContent" style="display: block;">

						<li v-for="h in hots">
							<a target="_blank" :href="'detail.html?pid=' + h.pid">
								<img :src="h.image" style="display: block;">
							</a>
						</li>

					</ul>
				</div>
			</div>
			<div class="span24">
				<div id="newProduct" class="newProduct clearfix">
					<div class="title">
						<strong>最新商品</strong>
						<a  target="_blank"></a>
					</div>
					<ul class="tab">
						<li class="current">
							<a href="./蔬菜分类.htm?tagIds=2" target="_blank"></a>
						</li>
						<li>
							<a  target="_blank"></a>
						</li>
						<li>
							<a target="_blank"></a>
						</li>
					</ul>
					<ul class="tabContent" style="display: block;">

						<li v-for="h in news">
							<a target="_blank" :href="'detail.html?pid=' + h.pid">
								<img :src="h.image" style="display: block;">
							</a>
						</li>

					</ul>
				</div>
			</div>
			<div class="span24">
				<div class="friendLink">
					<dl>
						<dd>新手指南</dd>
						<dd>
							<a  target="_blank">支付方式</a>
							|
						</dd>
						<dd>
							<a  target="_blank">配送方式</a>
							|
						</dd>
						<dd>
							<a  target="_blank">售后服务</a>
							|
						</dd>
						<dd>
							<a  target="_blank">购物帮助</a>
							|
						</dd>
						<dd>
							<a  target="_blank">蔬菜卡</a>
							|
						</dd>
						<dd>
							<a  target="_blank">礼品卡</a>
							|
						</dd>
						<dd>
							<a target="_blank">银联卡</a>
							|
						</dd>
						<dd>
							<a  target="_blank">亿家卡</a>
							|
						</dd>

						<dd class="more">
							<a >更多</a>
						</dd>
					</dl>
				</div>
			</div>
		</div>
	</damai>
</div>
<script>
	var v = new Vue({
		el : "#app",
		data : {
			hots :[],
			news :[],
			dacuTime: {},
			dacuProducts: [],
			dacuStopTime: null
		},
		created() {
			axios.get("/indexProduct").then(res=>{
				this.hots = res.data.hots;
				this.news = res.data.news;
			});
			axios.get("order/dacu/getTime").then(res=>{
				this.dacuTime = res.data;
				if(this.dacuTime.beginTime > 0){
					axios.get("order/dacu/getDacuProducts").then(res=>{
						this.dacuProducts = res.data;
					});
					var endTime = res.data.beginTime + res.data.length;
					setInterval(()=>{
						let time = endTime - new Date().getTime();
						this.dacuStopTime = new Date(time);
					},1000);
				}
			})
		},
		methods : {
			seckill(pid){
				if(this.$refs.dm.$refs.lg.user == null){
					this.$alert("请先登录系统!").then(()=>{
						location.href = "/login.html";
					})
				}
				let uid = this.$refs.dm.$refs.lg.user.uid;
				let num = 1;
				axios.get("order/dacu/seckill",{
					params : {
						pid : pid,
						uid : uid,
						num : num
					}
				}).then(res=>{
					if(res.data.code == 1){
						this.$message("秒杀成功!");
					} else {
						this.$alert(res.data.msg);
					}
				})
			}
		}
	})
</script>


</body></html>